package de.hm.edu.chartservice;

import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import de.hm.edu.kpi.KeyIndicator;


/** 
 * The ChartService REST Interface
 * 
 * @author Peter Goldenbogen (Munich University of Applied Science)
 * @version 1.0 
 */
public interface IChartService {

	/**
	 * Queries the current state of the Product Share KPI Instance
	 * @return A XML Representation of the Product Share KPI Instance
	 */
	@GET
	@Produces({ MediaType.APPLICATION_XML })
	@Path("/get_product_share")
	public abstract KeyIndicator getProductShareXmlKpi();

	/**
	 * Queries the current state of the Sales Volume KPI Instance
	 * @return A XML Representation of the Sales Volume KPI Instance
	 */
	@GET
	@Produces({ MediaType.APPLICATION_XML })
	@Path("/get_sales_volume")
	public abstract KeyIndicator getSalesVolumeXmlKpi();

	/**
	 * If a Order Request is received an OrderEvent will be created and the event is stored in DB
	 * @param product The ordered product
	 * @param amount The amount of products that have been ordered
	 * @return HTML String containing the requested params
	 * @throws Exception
	 */
	@POST
	@Produces({ MediaType.TEXT_HTML })
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Path("/add_order")
	public abstract String addOrderPost(@FormParam("product") String product,
			@FormParam("amount") int amount) throws Exception;

	/**
	 * Takes C2DM Registration requests and adds them to the recipients container
	 * 
	 * @param deviceId A key to identify devices
	 * @param registrationId A key created by C2DM Server and received from a client application
	 * @return Notification containing the send parameters
	 */
	@POST
	@Produces({ MediaType.TEXT_PLAIN })
	@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
	@Path("/clientC2DM")
	public abstract String receiveC2DMClientToken(
			@FormParam("deviceId") String deviceId,
			@FormParam("registrationId") String registrationId);

}